{include file='common/head' /}
<body>
    　　<script src="__LAYUI__/jq.js"></script>
<div class="x-nav">
          <span class="layui-breadcrumb">
              <a><cite>{$viewData['nav_title'][0]}</cite></a>
              <a><cite>{$viewData['nav_title'][1]}</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                {include file='common/sreachFrom' /}
                <div class="layui-card-header">
                    <button class="layui-btn" onclick="xadmin.open('添加优惠券','/admin/shop/coupon_edit','','',true)"><i class="layui-icon"></i>商品</button>
                    <!--<button class="layui-btn layui-btn-normal" title="点我批量改变" onclick="pinLiangStatusBtn('is_hot')">批量热门/不热门</button>-->
                    <span style="line-height:40px;float: right;">共有数据：{$count} 条</span>
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <td>序号</td>
                            {volist name="viewData['thead']" id="v"}
                            <th style="text-align: center;{$v.style|default=''}">{$v.title}</th>
                            {/volist}
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="list" id="v"}
                        <tr>
                            <td>
                                {$v.id}
                            </td>
                            <td>
                                {if $v->getShopUsersOne}
                                    <span onclick="copyCode('{$v->getShopUsersOne->id}')">商家序号：{$v->getShopUsersOne->id}</span>
                                    <hr>
                                    <span onclick="copyCode('{$v->getShopUsersOne->name}')">名称：{$v->getShopUsersOne->name}</span>
                                    <hr>
                                    <img width="80px" height="80px" src="{$v->getShopUsersOne->logo}" alt="">
                                {/if}
                            </td>
                            <td style="text-align: center;">
                                {if $v->getUserOne}
                                    昵称：<span onclick="copyCode('{$v->getUserOne->nickname}')">{$v->getUserOne->nickname}</span>
                                    <hr>
                                    序号：<span onclick="copyCode('{$v->getUserOne->id}')">{$v->getUserOne->id}</span>
                                    <hr>
                                    <img width="80px" height="80px" src="{$v->getUserOne->avatarurl}" alt="">
                                {/if}
                            </td>
                            <td style="text-align: center;">
                                {if $v->getShopCouponOne}
                                    优惠券序号：<span onclick="copyCode('{$v->getShopCouponOne->id}')">{$v->getShopCouponOne->id}</span>
                                    <hr>
                                    总量：<span onclick="copyCode('{$v->getShopCouponOne->total}')">{$v->getShopCouponOne->total}</span>
                                    <hr>
                                    领取数量：<span onclick="copyCode('{$v->getShopCouponOne->apply_num}')">{$v->getShopCouponOne->apply_num}</span>
                                    <hr>
                                    使用数量：<span onclick="copyCode('{$v->getShopCouponOne->use_num}')">{$v->getShopCouponOne->use_num}</span>
                                {/if}
                            </td>
                            <td style="text-align: center;">{$viewData['select_list']['type'][$v.type]}</td>
                            <td style="text-align: center;">{$viewData['select_list']['use_status'][$v.use_status]}</td>
                            <td style="text-align: center;">{$v.total_amount}</td>
                            <td style="text-align: center;">{$v.amount}</td>
                            <td style="text-align: center;">{$viewData['select_list']['status'][$v.status]}</td>
                            <td style="text-align: center;">
                                领取：{:date('Y-m-d H:i:s',$v['add_time'])}
                                <hr>
                                开始：{:date('Y-m-d H:i:s',$v['start_time'])}
                                <hr>
                                结束：{:date('Y-m-d H:i:s',$v['end_time'])}
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$page}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['form','laydate'], function(){
        var laydate = layui.laydate;
        var  form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });

        // 监听全选
        form.on('checkbox(checkall)', function(data){
            if(data.elem.checked){
                $('tbody input').prop('checked',true);
            }else{
                $('tbody input').prop('checked',false);
            }
            form.render('checkbox');
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });


    });

    /*删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                url:"{:url('Shop/coupon_del')}",
                type: "post",
                data:{id:id},
                dataType:"json",
                success:function (res) {
                    if(res.code == 200){
                        layer.msg('删除成功', {icon: 1,time:1000});
                        $(obj).parents("tr").remove();
                    }else{
                        layer.alert(res.msg, {icon:2,time:1000});
                    }
                },
                error:function(e){
                    layer.alert("网络错误", {icon:5,time:1000});
                },
            });
        });
    }

</script>
{include file='common/copyCode' /}
{include file='common/scroll' /}
{include file='common/footer' /}